package net.csdra.basis.service;

import net.csdra.basis.domain.EntityBase;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * Created by msf on 2018/1/25.
 */
public interface ServiceBaseInterface<T extends EntityBase, C extends ServiceBaseInterface.Create, U extends ServiceBaseInterface.Update> {
    T create(C c) throws IllegalAccessException, InstantiationException;

    T update(U u);

    /**
     * 此删除方法不会删除所有子级数据，只删除当前
     *
     * @param id
     */
    void deleteCurrent(String id);

    T enabledCurrent(String id, boolean isEnabled);

    T findOne(String id);

    T findOneAndEnabledIsTrue(String id);

    List<T> findAllByMetaId(String metaId);

    List<T> findAllByMetaId(String metaId, boolean isEnabled);

    Page<T> findPageByMetaId(String metaId, Pageable pageable);

    Page<T> findPageByMetaId(String metaId, boolean isEnabled, Pageable pageable);

    interface   Create {
        public String getMetaId();

        public void setMetaId(String metaId);

        public String getCustomize();

        public void setCustomize(String customize);
    }

    interface Update {


        public String getId();

        public void setId(String id);

        public String getCustomize();

        public void setCustomize(String customize);

        public boolean isEnabled();

        public boolean getEnabled();

        public void setEnabled(boolean enabled);

        public Long getOrder();

        public void setOrder(Long order);
    }
}
